package com.best.intelligentTrolley

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.blankj.utilcode.util.ConvertUtils
import com.blankj.utilcode.util.ToastUtils

class ConfirmDialog : DialogFragment() {

    override fun onStart() {
        super.onStart()
        //设置dialog的大小
        val lp: WindowManager.LayoutParams? = dialog?.window?.attributes
        lp?.width = ConvertUtils.dp2px(500f)
        lp?.height = WindowManager.LayoutParams.WRAP_CONTENT
        lp?.dimAmount = 0f
        dialog?.window?.attributes = lp
        dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialog?.setCanceledOnTouchOutside(false)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.dialog_confirm, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        var tvCancel = view.findViewById<TextView>(R.id.tv_cancel)
        var tvSure = view.findViewById<TextView>(R.id.tv_sure)

        tvSure.setOnClickListener {
            Config.resetPlasmaModuleUsageTime()
            ToastUtils.showLong("重置成功！")
            dismiss()
        }
        tvCancel.setOnClickListener {
            dismiss()
        }
    }




}